import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

// 引入组件
import Layout from '@/views/layout/Layout.vue';
import Login from '@/views/login/Login.vue';

const routes = [
  {
    path:'/',
    redirect:"/account"
  },
{
  path:'/',
  redirect:"/login"
},
  // 登录页
  {
    path:'/login',
    meta:{title:'登录页面'},
    component:Login,

  },  

  // 框架页
  {
    path:'/layout',
    meta:{title:'后台首页'},
    component:Layout,
    redirect:'/layout',
    children:[
      {path:'/home',meta:{title:'后台首页'},component:()=>import('@/views/home/Home.vue')}
    ]
  },
  // 订单管理
  {
      path:'/order',
      meta:{title:'订单管理'},
      component:Layout,
      redirect:'/order',
      children:[
        {path:'/order',meta:{title:'订单详情'},component:()=>import('@/views/order/OrderList.vue')}
      ]
  },
  // 账号管理
  {
      path:'/account',
      meta:{title:'账号管理'},
      component:Layout,
      redirect:'/account/accountlist',
      children:[
        {path:'/account/accountlist',meta:{title:'账号列表'},component:()=>import('@/views/account/AccountList.vue')},
        {path:'/account/accountadd',meta:{title:'账号添加'},component:()=>import('@/views/account/AccountAdd.vue')},
        {path:'/account/accountmodification',meta:{title:'修改密码'},component:()=>import('@/views/account/AccountModification.vue')},
        {path:'/account/personal',component:()=>import('@/views/account/Personal.vue')},
      ]
  },
  // 店铺管理
    {
      path:'/shop',
      meta:{title:'店铺管理'},
      component:Layout,
      redirect:'/shop',
      children:[
        {path:'/shop',meta:{title:'店铺详情'},component:()=>import('@/views/shop/Shop.vue')}
      ]
    },
  // 商品管理
  {
    path:'/goods',
    meta:{title:'商品管理'},
    component:Layout,
    redirect:'/goods/goodslist',
    children:[
      {path:'/goods/goodslist',meta:{title:'商品列表'},component:()=>import('@/views/goods/GoodsList.vue')},
      {path:'/goods/goodsadd',meta:{title:'商品添加'},component:()=>import('@/views/goods/GoodsAdd.vue')},
      {path:'/goods/goodsclassify',meta:{title:'商品分类q'},component:()=>import('@/views/goods/GoodsClassify.vue')},
    ]
  },
  // 统计管理
  {
    path:'/total',
    meta:{title:'统计管理'},
    component:Layout,
    redirect:'/total/totalgoods',
    children:[
      {path:'/total/totalgoods',meta:{title:'商品统计'},component:()=>import('@/views/total/TotalGoods.vue')},
      {path:'/total/totalorder',meta:{title:'订单统计'},component:()=>import('@/views/total/TotalOrder.vue')},
      
    ]
  },

  // 404页面
  {
    path:"*",
    component:()=>import('@/views/NotFound.vue')
  },
  
 
]

const router = new VueRouter({
  routes
})



// 防止重新路由跳转
// 获取原型对象puush函数
const originalPush=VueRouter.prototype.push;

// 修改原型对象中的push函数
VueRouter.prototype.push=function push(location){
  return originalPush.call(this,location).catch(err=>err)
}

export default router
